package org.ring.rpc;

import org.ring.common.URL;
import org.ring.common.transport.ClientTransport;
import org.ring.common.transport.Connection;
import org.ring.common.transport.TransportConfig;

/**
 * @since 2024-10-28 20:20
 */
public class DefaultProtocol implements Protocol{

    private ClientTransport transport;
   // private Map<String,Connection> connections = new ConcurrentHashMap<>();
    public DefaultProtocol(){
        TransportConfig transportConfig = new TransportConfig();
        ClientTransport clientTransport = new ClientTransport(transportConfig);
        this.transport = clientTransport;
    }

    @Override
    public Invoker refer(URL url) {

        Connection connection = this.transport.connect(url);
       // connections.put(url,connection);
        return new DefaultInvoker(url,connection);
    }
}
